<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2017/11/27
  Time: 12:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <c:set var="root" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <link href="${root}/css3/bootstrap.css" rel="stylesheet" type="text/css" />
    <script src="${root}/js3/bootstrap.js"></script>
    <script src="${root}/js3/jquery-2.1.0.js"></script>
    <title>修改页面</title>
</head>
<body>
<!--  -->
<form id="userAction_save_do" action="${pageContext.request.contextPath}/manage/updateTwoProduct.do" name="Form1"  enctype="multipart/form-data">
  <input type="hidden" name="pid" value="${product.pid}">

  &nbsp;
  <table cellSpacing="1" cellPadding="5" width="100%" align="center" bgColor="#eeeeee" style="border: 1px solid #8ba7e3" border="0">
    <tr>
      <td class="ta_01" align="center" bgColor="#afd1f3" colSpan="4"
          height="26">
        <strong><STRONG>编辑商品</STRONG>
        </strong>
      </td>
    </tr>

    <tr>
      <td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
        商品名称：
      </td>
      <td class="ta_01" bgColor="#ffffff">
        <input type="text" name="pname" value="${product.pname}" id="pname" class="bg"/>
      </td>
      <td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
        库存：
      </td>
      <td class="ta_01" bgColor="#ffffff">
        <input type="text" name="counts" value="${product.counts}" id="counts" class="bg"/>
      </td>
    </tr>
    <tr>
      <td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
        价格：
      </td>
      <td class="ta_01" bgColor="#ffffff">
        <input type="text" name="price" value="${product.price}" id="price" class="bg"/>
      </td>
    </tr>
    <tr>
      <td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
        商品图片：
      </td>
      <td class="ta_01" bgColor="#ffffff" colspan="3">
        <div>
          <img id="image" name="image" src="${pageContext.request.contextPath}/static/${product.image}" alt="${product.pname}" >
        </div>
      </td>
    </tr>
    <tr>
      <td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
        所属分类：
      </td>

      <td class="ta_01" bgColor="#ffffff" colspan="3">

        <select id="type" name="type">
          <c:forEach items="${categoryList}" var="categoryList">
            <c:if test="${requestScope.product.type != categoryList.cid}">
              <option value="${categoryList.cid}" selected="selected">${categoryList.cname}</option>
            </c:if>

            <c:if test="${requestScope.product.type == categoryList.cid}">
              <option value="${categoryList.cid}"name="${categoryList.cid}">${categoryList.cname}</option>
            </c:if>
          </c:forEach>
        </select>

      </td>

    </tr>
    <tr>
      <td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
        商品描述：
      </td>
      <td class="ta_01" bgColor="#ffffff" colspan="3">
        <textarea name="describe" id="describe" value="${product.describe}" rows="5" cols="30">${product.describe}</textarea>
      </td>
    </tr>
    <tr>
      <td class="ta_01" style="WIDTH: 100%" align="center"
          bgColor="#f5fafe" colSpan="4">
        <button type="submit" id="userAction_save_do_submit" value="确定"  class="button_ok">
          &#30830;&#23450;
        </button>

        <FONT face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT>
        <button type="reset" value="重置" class="button_cancel">&#37325;&#32622;</button>

        <FONT face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT>
        <INPUT class="button_ok" type="button" onclick="history.go(-1)" value="返回"/>
        <span id="Label1"></span>
      </td>
    </tr>
  </table>
</form>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/js3/jquery-1.11.3.min.js"></script>

<script>
  function update() {
    $.ajax({
      type : "POST",
      url : "${pageContext.request.contextPath}/manage/updateTwoProduct.do?id=${product.pid}",
      data : {
        name : $("#name").val(),
        stock : $("#stock").val(),
        price : $("input[name='price']").val(),
        category : $("#category").val(),
        detail : $("#detail").val()
      },
      success : function () {
        location.href = "${pageContext.request.contextPath}/manage/displayTwoProduct.do?pageNum=0"
      }
    });
  }
</script>
</html>
